using System;
using System.Data;
using System.Xml;

using OR.Reuse.Persistence;

using Derived = OR.Lazarus.Business.Entities.ConfigList;

namespace OR.Lazarus.Business.Entities.ConfigList.Lazarus
{
	/// <summary>
	/// The root node of a config list document.
	/// </summary>
   public class KnownConfigsDetail : EntityBase
   {
		protected System.String mName;
		protected System.DateTime mLastChecked;
		protected string mDescription;

		public KnownConfigsDetail()
		{
	
		}
	
		/// <summary>
		/// 
		/// </summary>
		public System.String Name
		{
			get
			{
				return ( mName );
			}
			set
			{
				mName = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public System.DateTime LastChecked
		{
			get
			{
				return ( mLastChecked );
			}
			set
			{
				mLastChecked = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Description
		{
			get
			{
				return ( mDescription );
			}
			set
			{
				mDescription = value;
			}
		}

		public override void LoadXml( XmlElement pSource )
		{
			// Scalar Values
			mName = DataUtility.GetString( pSource, "name" );
			mLastChecked = DataUtility.GetDateTime( pSource, "last-checked", DateTime.Now );
			XmlElement vDescription = ( XmlElement )pSource.SelectSingleNode( "lcfs:description", PersistenceConfig.Namespaces );
			
			if ( vDescription != null )
			{
				mDescription = vDescription.InnerText;
			}
			
		}
		
		public override XmlElement SaveXml( XmlDocument p_docContext )
		{
			XmlElement vNewElement	= p_docContext.CreateElement( "lcfs", "known-configs", "http://schemas.icitadel.com/Lazarus/ConfigList.xsd" );

			// Scalar Values
			if ( !String.IsNullOrEmpty( mName ) )
			{
				vNewElement.SetAttribute( "name", mName );
			}
					
			vNewElement.SetAttribute( "last-checked", mLastChecked.ToString() );
			if ( !String.IsNullOrEmpty( mDescription ) )
			{
				XmlElement	vDescription = p_docContext.CreateElement( "lcfs", "description", "http://schemas.icitadel.com/Lazarus/ConfigList.xsd" );
				vDescription.InnerText = mDescription;
				vNewElement.AppendChild( vDescription );
			}
					

			return ( vNewElement );
		}

		public virtual object Clone()
		{
			Derived.KnownConfigsDetail v_oReturn = new Derived.KnownConfigsDetail();
			
			v_oReturn.Name = mName;
			v_oReturn.LastChecked = mLastChecked;
			v_oReturn.Description = mDescription;
			
			// FK Values

			// Collections
			
			return ( v_oReturn );
		}

		public virtual Derived.KnownConfigsDetail CloneTyped()
		{
			return ( ( Derived.KnownConfigsDetail )this.Clone() );
		}
   }
}
   